/**
 * @Author Yunfeng Bai
 *
 * 2010-10-30
 */
package collision;

import javax.vecmath.Point3d;
import javax.vecmath.Vector3d;

import rigidbody.RigidBody;

/**
 * The class that stores collision data.
 * Point collision only.
 */
public class Collision
{
    public double penetrationDepth;
    public RigidBody object1, object2;
    /**
     * This normal vector will always point from i to j,
     * where i holds the collision point.
     */
    public Vector3d normal;
    public Point3d positionInWorld;
    /**
     * The type of collision. There are basically two types.
     * type = 0: using the exact contact point pairs.
     * type = 1: using the deepest penetration point.
     */
    public int type;
    
    public Collision() {}
    
    public Collision(double overlapDepth_, RigidBody obj1_, RigidBody obj2_,
            Vector3d normal_)
    {
        this(overlapDepth_, obj1_, obj2_, null, normal_);
    }
    
    public Collision(double overlapDepth_, RigidBody obj1_, RigidBody obj2_,
            Point3d positionInWorld_, Vector3d normal_)
    {
    	positionInWorld = positionInWorld_;
        penetrationDepth = overlapDepth_;
        object1 = obj1_;
        object2 = obj2_;
        normal = normal_;
    }
    
    @Override
    public String toString()
    {
    	return String.format("%s hits %s at %s",
    				object1.getName(), object2.getName(), positionInWorld);
    }
}
